get last id ef

61

get last id ef -

//Grab the highest value using the Max() method
int max = db.Products.Max(p => p.ID);

get last id ef -

//Grab the highest ID value using the OrderByDescending() method
var max = db.Products.OrderByDescending(p => p.ID).FirstOrDefault().ID;

Comments

Submit
0 Comments